<template>
    <view class="takeNotes">

        <view class="inputValueBox" v-if="pageType != 4">
            <u--input focus v-model="valueData" customStyle="background: #F2F4F4;" @confirm="on_confirm" shape="circle"
                :adjustPosition="false" fontSize="14px" border="true" :placeholder="placeholderValue" prefixIcon="search"
                prefixIconStyle="font-size: 22px;color: #0000000;font-weight: 700;" />
        </view>

        <!-- 积分记录  -->
        <view v-if="pageType == 1">
            <view class="title">当前剩余积分：{{ integralRecord.user_integral }}</view>
            <view class="table">
                <view class="ul" v-for="item in integralRecord.List" :key="item.id">
                    <view class="li">
                        <view class="name">订单号：</view>
                        <view class="value">{{ item.order_sn }}</view>
                    </view>

                    <view class="li">
                        <view class="name">订单类型：</view>
                        <view class="value">{{ item.order_type == 1 ? '普通订单' : item.order_type == 2 ? '团购订单' : '年定订单' }}
                        </view>
                    </view>
                    <view class="li">
                        <view class="name">收益分类：</view>
                        <view class="value">{{ (item.profit == 1 ? '园主补贴' : item.profit == 2 ? '直推业绩' : item.profit == 3 ?
                            '间推业绩' :
                            item.profit == 4 ? '团长差价' : '') }}</view>
                    </view>
                    <view class="li">
                        <view class="name">积分状态：</view>
                        <view class="value"> {{ (item.status == 0 ? '未发放' : item.status == 1 ? '已发放' : item.status == 2 ?
                            '退款退回' : '') }}</view>
                    </view>
                    <view class="li">
                        <view class="name">差价或积分：</view>
                        <view class="value">{{ item.commission }}</view>
                    </view>
                    <view class="li">
                        <view class="name">发放时间：</view>
                        <view class="value">{{ item.addtime }}</view>
                    </view>
                    <view class="li">
                        <view class="name">描述：</view>
                        <view class="value">{{ item.msg }}</view>
                    </view>

                </view>
            </view>
            <view v-if="integralRecord.List.length <= 0" class="noData">暂无数据</view>
        </view>

        <!-- 积分明细  -->
        <view v-if="pageType == 2">
            <view class="table">
                <view class="ul" v-for="item in pointsDetailsList" :key="item.id">
                    <view class="li">
                        <view class="name">用户ID：</view>
                        <view class="value">{{ item.user_id }}</view>
                    </view>

                    <view class="li">
                        <view class="name">订单号：</view>
                        <view class="value">{{ item.log_sn }}

                        </view>
                    </view>
                    <view class="li">
                        <view class="name">积分类型：</view>
                        <view class="value">
                            {{ (item.source_type == 100 ? '余额充值' : item.source_type == 200 ? '成为园主' : item.source_type ==
                                300 ?
                                '购买商品' : item.source_type == 400 ? '退款退回' : item.source_type == 500 ? '取消订单' : item.source_type
                                    == 600 ?
                                    '后台操作' : '') }}
                        </view>
                    </view>
                    <view class="li">
                        <view class="name">变动总数：</view>
                        <view class="value"> {{ item.change_amount }}</view>
                    </view>
                    <view class="li">
                        <view class="name">剩余总数：</view>
                        <view class="value">{{ item.left_amount }}</view>
                    </view>
                    <view class="li">
                        <view class="name">说明：</view>
                        <view class="value">{{ item.remark }}</view>
                    </view>
                    <view class="li">
                        <view class="name">后台操作人：</view>
                        <view class="value">{{ item.operator }}</view>
                    </view>
                    <view class="li">
                        <view class="name">变动时间：</view>
                        <view class="value">{{ item.addtime }}</view>
                    </view>
                </view>
            </view>
            <view v-if="pointsDetailsList.length <= 0" class="noData">暂无数据</view>
        </view>


        <!-- 余额明细  -->
        <view v-if="pageType == 3">
            <view class="table">
                <view class="table">
                    <view class="ul" v-for="item in alanceDetailsList" :key="item.id">
                        <view class="li">
                            <view class="name">用户ID：</view>
                            <view class="value">{{ item.user_id }}</view>
                        </view>

                        <view class="li">
                            <view class="name">流水号：</view>
                            <view class="value">{{ item.log_sn }}

                            </view>
                        </view>
                        <view class="li">
                            <view class="name">积分类型：</view>
                            <view class="value">
                                {{ (item.source_type == 100 ? '余额充值' : item.source_type == 200 ? '成为园主' : item.source_type
                                    ==
                                    300 ?
                                    '购买商品' : item.source_type == 400 ? '退款退回' : item.source_type == 500 ? '取消订单' :
                                        item.source_type
                                            == 600 ?
                                            '后台操作' : '') }}
                            </view>
                        </view>
                        <view class="li">
                            <view class="name">变动总数：</view>
                            <view class="value"> {{ item.change_amount }}</view>
                        </view>
                        <view class="li">
                            <view class="name">剩余总数：</view>
                            <view class="value">{{ item.left_amount }}</view>
                        </view>
                        <view class="li">
                            <view class="name">说明：</view>
                            <view class="value">{{ item.remark }}</view>
                        </view>

                        <view class="li">
                            <view class="name">添加时间：</view>
                            <view class="value">{{ item.addtime }}</view>
                        </view>
                        <view class="li">
                            <view class="name">昵称：</view>
                            <view class="value">{{ item.nickname }}</view>
                        </view>
                        <view class="li">
                            <view class="name">手机号：</view>
                            <view class="value">{{ item.mobile }}</view>
                        </view>
                        <view class="li">
                            <view class="name">真实姓名：</view>
                            <view class="value">{{ item.alipay_name }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view v-if="alanceDetailsList.length <= 0" class="noData">暂无数据</view>

        </view>


        <!-- 提现明细  -->
        <view v-if="pageType == 4">
            <view class="title">当前剩余积分：{{ integral }} <text style="margin-left:20rpx">提现总额：{{ withdraw_fee }}</text></view>
            <view class="table">
                <view class="table">
                    <view class="ul" v-for="item in cashWithdrawalDetailsList" :key="item.id">
                        <view class="li">
                            <view class="name">用户ID：</view>
                            <view class="value">{{ item.user_id }}</view>
                        </view>

                        <view class="li">
                            <view class="name">流水号：</view>
                            <view class="value">{{ item.log_sn }}

                            </view>
                        </view>
                        <view class="li">
                            <view class="name">提现金额：</view>
                            <view class="value"> {{ item.withdraw_fee }}</view>
                        </view>
                        <view class="li">
                            <view class="name">状态：</view>
                            <view class="value">
                                {{ (item.state == 1 ? '提交申请' : item.state == 2 ? '审核中' : item.state == 3 ? '审核失败' :
                                    item.state == 4 ?
                                        '审核通过' :
                                        '') }}
                            </view>
                        </view>

                        <view class="li">
                            <view class="name">申请时间：</view>
                            <view class="value">{{ item.withdraw_date }}</view>
                        </view>
                        <view class="li">
                            <view class="name">用户真实姓名：</view>
                            <view class="value">{{ item.alipay_name }}</view>
                        </view>

                        <view class="li">
                            <view class="name">用户手机号：</view>
                            <view class="value">{{ item.mobile }}</view>
                        </view>
                        <view class="li">
                            <view class="name">提现失败原因：</view>
                            <view class="value">{{ item.fail_reason }}</view>
                        </view>
                        <view class="li">
                            <view class="name">模板消息状态：</view>
                            <view class="value">{{ item.is_send_template_message == 0 ? '没发送' :
                                item.is_send_template_message == 1 ? '已发送' :
                                    item.is_send_template_message == 2 ? '发送失败' : '' }}</view>
                        </view>
                        <view class="li">
                            <view class="name">模板消息失败原因：</view>
                            <view class="value">{{ item.send_reason }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view v-if="cashWithdrawalDetailsList.length <= 0" class="noData">暂无数据</view>
        </view>

        <!-- 直推列表  -->
        <view v-if="pageType == 5">
            <view class="table">
                <view class="table">
                    <view class="ul" v-for="item in directPushList" :key="item.id">
                        <view class="li">
                            <view class="name">用户ID：</view>
                            <view class="value">{{ item.id }}</view>
                        </view>

                        <view class="li">
                            <view class="name">用户昵称：</view>
                            <view class="value">{{ item.nickname }}

                            </view>
                        </view>
                        <view class="li">
                            <view class="name">用户手机号：</view>
                            <view class="value"> {{ item.mobile }}</view>
                        </view>
                        <view class="li">
                            <view class="name">性别：</view>
                            <view class="value">
                                {{ (item.sex == 0 ? '未知' : item.sex = 1 ? '男' : '女') }}
                            </view>
                        </view>

                        <view class="li">
                            <view class="name">会员等级：</view>
                            <view class="value">
                                {{ (item.level == 0 ? '普通用户' : item.level == 1 ? '园长' : '团长') }}
                            </view>
                        </view>
                        <view class="li">
                            <view class="name">团队名称：</view>
                            <view class="value">{{ item.team_name }}</view>
                        </view>

                        <view class="li">
                            <view class="name">第一上级：</view>
                            <view class="value">{{ item.pid }}</view>
                        </view>
                        <view class="li">
                            <view class="name">间推上级：</view>
                            <view class="value">{{ item.gid }}</view>
                        </view>

                        <view class="li">
                            <view class="name">上级数量：</view>
                            <view class="value">{{ item.depth }}</view>
                        </view>
                        <view class="li">
                            <view class="name">金额：</view>
                            <view class="value">{{ item.money }}</view>
                        </view>
                        <view class="li">
                            <view class="name">已消费金额：</view>
                            <view class="value">{{ item.yxf_money }}</view>
                        </view>
                        <view class="li">
                            <view class="name">积分：</view>
                            <view class="value">{{ item.integral }}</view>
                        </view>
                        <view class="li">
                            <view class="name">是否新用户：</view>
                            <view class="value">{{ (item.is_old_user == 1 ? '旧系统用户' : '新用户') }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view v-if="directPushList.length <= 0" class="noData">暂无数据</view>

        </view>

        <!-- 间推列表  -->
        <view v-if="pageType == 6">
            <view class="table">
                <view class="table">
                    <view class="ul" v-for="item in interPushList" :key="item.id">
                        <view class="li">
                            <view class="name">用户ID：</view>
                            <view class="value">{{ item.id }}</view>
                        </view>

                        <view class="li">
                            <view class="name">用户昵称：</view>
                            <view class="value">{{ item.nickname }}

                            </view>
                        </view>
                        <view class="li">
                            <view class="name">用户手机号：</view>
                            <view class="value"> {{ item.mobile }}</view>
                        </view>
                        <view class="li">
                            <view class="name">性别：</view>
                            <view class="value">
                                {{ (item.sex == 0 ? '未知' : item.sex = 1 ? '男' : '女') }}
                            </view>
                        </view>

                        <view class="li">
                            <view class="name">会员等级：</view>
                            <view class="value">
                                {{ (item.level == 0 ? '普通用户' : item.level == 1 ? '园长' : '团长') }}
                            </view>
                        </view>
                        <view class="li">
                            <view class="name">团队名称：</view>
                            <view class="value">{{ item.team_name }}</view>
                        </view>

                        <view class="li">
                            <view class="name">第一上级：</view>
                            <view class="value">{{ item.pid }}</view>
                        </view>
                        <view class="li">
                            <view class="name">间推上级：</view>
                            <view class="value">{{ item.gid }}</view>
                        </view>

                        <view class="li">
                            <view class="name">上级数量：</view>
                            <view class="value">{{ item.depth }}</view>
                        </view>
                        <view class="li">
                            <view class="name">金额：</view>
                            <view class="value">{{ item.money }}</view>
                        </view>
                        <view class="li">
                            <view class="name">已消费金额：</view>
                            <view class="value">{{ item.yxf_money }}</view>
                        </view>
                        <view class="li">
                            <view class="name">积分：</view>
                            <view class="value">{{ item.integral }}</view>
                        </view>
                        <view class="li">
                            <view class="name">是否新用户：</view>
                            <view class="value">{{ (item.is_old_user == 1 ? '旧系统用户' : '新用户') }}</view>
                        </view>
                    </view>
                </view>
            </view>
            <view v-if="interPushList.length <= 0" class="noData">暂无数据</view>

        </view>
		<!-- 直播红包明细  -->
		<view v-if="pageType == 7">
		    <view class="table">
		        <view class="ul" v-for="item in acontributionWalletList" :key="item.id">
		            <view class="li">
		                <view class="name">用户ID：</view>
		                <view class="value">{{ item.user_id }}</view>
		            </view>
		
		            <view class="li">
		                <view class="name">类型：</view>
		                <view class="value">
		                    {{ (item.type == 1 ? '增加' : item.source_type == 2 ? '减少' : '') }}
		
		                </view>
		            </view>
		            <view class="li">
		                <view class="name">变动直播红包：</view>
		                <view class="value"> {{ item.contribution }}</view>
		            </view>
		            <view class="li">
		                <view class="name">变动前直播红包：</view>
		                <view class="value">{{ item.left_contribution }}</view>
		            </view>
		            <view class="li">
		                <view class="name">说明：</view>
		                <view class="value">{{ item.msg }}</view>
		            </view>
		            <view class="li">
		                <view class="name">变动时间：</view>
		                <view class="value">{{ item.addtime }}</view>
		            </view>
		        </view>
		    </view>
		    <view v-if="acontributionWalletList.length <= 0" class="noData">暂无数据</view>
		</view>

        <view class="pagination" v-if="total">
            <uni-pagination @change="on_change" title="标题文字" :total="total"></uni-pagination>
            <view class="example">
                <text class="example-info">当前页：{{ page }}，数据总量：{{ total }}条，每页数据：{{ 10
                }}</text>
            </view>
        </view>

        <u-loading-page loading-color="#1890ff" color="#fff" bg-color="rgba(0, 0, 0, 0.5)"
            :loading="loadingType"></u-loading-page>
    </view>
</template>


<script>
import tTable from '@/components/t-table/t-table.vue';
import tTh from '@/components/t-table/t-th.vue';
import tTr from '@/components/t-table/t-tr.vue';
import tTd from '@/components/t-table/t-td.vue';
export default {
    components: {
        tTable,
        tTh,
        tTr,
        tTd
    },
    data() {
        return {
            withdraw_fee: 0,
            integral: 0,
            page: 1,
            total: 0,
            valueData: '',
            pageType: 1,
            integralRecord: {
                List: [],
                user_integral: 0
            },
            pointsDetailsList: [],
            alanceDetailsList: [],
            cashWithdrawalDetailsList: [],
            directPushList: [],
            interPushList: [],
			acontributionWalletList:[],
            loadingType: false,
            userId: '',
            user_mobile: '',
            placeholderValue: ''
        };
    },
    onLoad(data) {
        this.pageType = data.type
        this.userId = JSON.parse(data.item).id
        this.user_mobile = JSON.parse(data.item).mobile
        if (data.type == 1) {
            uni.setNavigationBarTitle({
                title: '积分记录'
            })
            this.placeholderValue = '请输入订单号'
            this.ajax_userUserMsg()
        }
        if (data.type == 2) {
            uni.setNavigationBarTitle({
                title: '积分明细'
            })
            this.placeholderValue = '请输入用户手机号'
            this.ajax_pointsDetails()
        }
        if (data.type == 3) {
            uni.setNavigationBarTitle({
                title: '余额明细'
            })
            this.placeholderValue = '请输入用户手机号'
            this.ajax_userBalanceList()
        }
        if (data.type == 4) {
            uni.setNavigationBarTitle({
                title: '提现明细'
            })
            this.integral = JSON.parse(data.item).integral
            this.ajax_userWithdrawalList()
        }
        if (data.type == 5) {
            uni.setNavigationBarTitle({
                title: '直推列表'
            })
            this.placeholderValue = '请输入用户手机号'
            this.ajax_findUserList()

        } if (data.type == 6) {
            uni.setNavigationBarTitle({
                title: '间推列表'
            })
            this.placeholderValue = '请输入用户手机号'
            this.ajax_twoUserList()
        } if (data.type == 7) {
            uni.setNavigationBarTitle({
                title: '直播红包明细'
            })
            this.placeholderValue = '请输入用户ID'
            this.ajax_acontributionWalletList()
        }

    },
    methods: {
        on_confirm() {
            this.page = 1;
            if (this.pageType == 1) {
                this.ajax_userUserMsg()
            }
            if (this.pageType == 2) {
                this.ajax_pointsDetails()
            }
            if (this.pageType == 3) {
                this.ajax_userBalanceList()
            }
            if (this.pageType == 4) {
                this.ajax_userWithdrawalList()
            }
            if (this.pageType == 5) {
                this.ajax_findUserList()
            }
            if (this.pageType == 6) {
                this.ajax_twoUserList()
            }
            if (this.pageType == 7) {
                this.ajax_acontributionWalletList()
            }
        },
        on_change(page) {
            this.page = page.current;
            if (this.pageType == 1) {
                this.ajax_userUserMsg()
            }
            if (this.pageType == 2) {
                this.ajax_pointsDetails()
            }
            if (this.pageType == 3) {
                this.ajax_userBalanceList()
            }
            if (this.pageType == 4) {
                this.ajax_userWithdrawalList()
            }
            if (this.pageType == 5) {
                this.ajax_findUserList()
            }
            if (this.pageType == 6) {
                this.ajax_twoUserList()
            }
            if (this.pageType == 7) {
                this.ajax_acontributionWalletList()
            }
        },
        // 间推列表
        ajax_twoUserList() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/twoUserList',
                method: 'POST',
                data: {
                    page: this.page,
                    userId: this.userId,
                    mobile: this.valueData
                }
            }).then(res => {
                this.interPushList = res.data.list.data;
                this.total = res.data.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
        // 直推列表
        ajax_findUserList() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/findUserList',
                method: 'POST',
                data: {
                    page: this.page,
                    userId: this.userId,
                    mobile: this.valueData
                }
            }).then(res => {
                this.directPushList = res.data.list.data;
                this.total = res.data.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
        // 提现明细
        ajax_userWithdrawalList() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/userWithdrawalList',
                method: 'POST',
                data: {
                    page: this.page,
                    user_id: this.userId,
                    mobile: this.valueData
                }
            }).then(res => {
                this.cashWithdrawalDetailsList = res.data.list.list.data;
                this.withdraw_fee = res.data.list.withdraw_fee
                this.total = res.data.list.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
        // 余额明细
        ajax_userBalanceList() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/userBalanceList',
                method: 'POST',
                data: {
                    page: this.page,
                    user_id: this.userId,
                    mobile: this.valueData
                }
            }).then(res => {
                this.alanceDetailsList = res.data.list.list.data;
                this.total = res.data.list.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
        // 积分明细
        ajax_pointsDetails() {
            this.loadingType = true;
            this.$request.request({
                url: 'Finance/pointsDetails',
                method: 'POST',
                data: {
                    page: this.page,
                    user_id: this.userId,
                    user_mobile: this.valueData
                }
            }).then(res => {
                this.pointsDetailsList = res.data.list.data;
                this.total = res.data.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
        // 直播红包明细
        ajax_acontributionWalletList() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/contributionWalletList',
                method: 'POST',
                data: {
                    page: this.page,
                    id: this.userId?this.userId:this.valueData
                }
            }).then(res => {
                this.acontributionWalletList = res.data.list.list.data;
                this.total = res.data.list.list.total;
            }).finally(() => {
                this.loadingType = false;
            })
        },
		
        // 积分记录
        ajax_userUserMsg() {
            this.loadingType = true;
            this.$request.request({
                url: 'user/userMsg',
                method: 'POST',
                data: {
                    page: this.page,
                    user_mobile: this.user_mobile,
                    order_sn: this.valueData
                }
            }).then(res => {
                this.integralRecord.List = res.data.user.list.data;
                this.total = res.data.user.list.total;
                this.integralRecord.user_integral = res.data.user.user_integral

            }).finally(() => {
                this.loadingType = false;
            })
        },
    },
};
</script>
<style lang="scss" scoped>
.takeNotes {
    padding: 20rpx;

    .title {
        margin: 20rpx 0 0 0;
        font-size: 14px;
        font-weight: 700;
    }

    .table {
        .ul {
            margin-top: 25rpx;
            font-size: 14px;
            border-bottom: 1px solid #ccc;
            padding-bottom: 25rpx;

            .li {
                display: flex;
                margin-top: 10rpx;

                .name {
                    white-space: nowrap;
                }
            }
        }

        .ul:nth-child(1) {
            margin-top: 0 !important;
        }

        .ul:nth-last-child(1) {
            border-bottom: none;
        }
    }
}
</style>